{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  谢新沪\n",
    "+ 学号  0162485"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a不是贫苦户\n",
      "b不是贫苦户\n",
      "c是贫苦户\n",
      "c不是贫苦户\n"
     ]
    }
   ],
   "source": [
    "class Poor():\n",
    "    def __init__(self,name,education,housing,drinking,diet):\n",
    "        #### 有保障则值为True，反之为False\n",
    "        self.name = name\n",
    "        self.education = education\n",
    "        self.housing = housing\n",
    "        self.drinking = drinking\n",
    "        self.diet = diet\n",
    "    def yuche(self):\n",
    "        if int(self.education)+int(self.housing)+int(self.drinking)+int(self.diet)<2 :\n",
    "            print(self.name + \"是贫苦户\")\n",
    "        else :\n",
    "            print(self.name + \"不是贫苦户\")\n",
    "poor_a = Poor(\"a\",True,True,True,True)\n",
    "poor_a.yuche()\n",
    "poor_b = Poor(\"b\",True,False,True,False)\n",
    "poor_b.yuche()\n",
    "poor_c = Poor(\"c\",False,False,False,True)\n",
    "poor_c.yuche()\n",
    "poor_c.edcation = True\n",
    "poor_c.housing = True\n",
    "poor_c.drinking = True\n",
    "poor_c.yuche()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a的BMI可能偏大\n",
      "b的体重正常\n",
      "c的体重正常\n"
     ]
    }
   ],
   "source": [
    "class Student():\n",
    "    def __init__(self,name,grade,sleeptime):\n",
    "        self.name = name\n",
    "        self.grade = grade\n",
    "        self.sleeptime = sleeptime\n",
    "        self.sta_grade = 90\n",
    "        self.sta_sleeptime = 6\n",
    "    def yuche(self):\n",
    "        if self.grade > self.sta_grade and self.sleeptime < self.sta_sleeptime:\n",
    "            print(self.name + \"的BMI可能偏大\")\n",
    "        else :\n",
    "            print(self.name + \"的体重正常\")\n",
    "student_a = Student(\"a\",91,5)\n",
    "student_a.yuche()\n",
    "student_b = Student(\"b\",89,5)\n",
    "student_b.yuche()\n",
    "student_c = Student(\"c\",91,7)\n",
    "student_c.yuche()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a趋向正常\n",
      "b的BMI可能偏大\n",
      "c的体重正常\n"
     ]
    }
   ],
   "source": [
    "class Running_members(Student):\n",
    "    def __init__(self,name,grade,sleeptime,runningtime):\n",
    "        super().__init__(name,grade,sleeptime)\n",
    "        self.runningtime = runningtime\n",
    "    def yuche(self):\n",
    "        if self.grade > self.sta_grade and self.sleeptime < self.sta_sleeptime and self.runningtime > 30:\n",
    "            print(self.name + \"趋向正常\")\n",
    "        elif self.grade > self.sta_grade and self.sleeptime < self.sta_sleeptime and self.runningtime <= 30:\n",
    "             print(self.name + \"的BMI可能偏大\")\n",
    "        else :\n",
    "            print(self.name + \"的体重正常\")\n",
    "running_member_a = Running_members(\"a\",91,5,31)\n",
    "running_member_a.yuche()\n",
    "running_member_b = Running_members(\"b\",91,5,29)\n",
    "running_member_b.yuche()\n",
    "running_member_c = Running_members(\"c\",89,5,30)\n",
    "running_member_c.yuche()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
